<template>
	<view>
		<view class="box">
			<view class="menu_content_box_page">
				<view class="pa15">

					<view class="mt15 area_block_1" v-for="item, index in list" :key="index">
						<view class="fs28 fwb cor_000">{{item.type}}</view>
						<view class="mt20 flex_box">
							<view class="re mr25">
								<image :lazy-load="true" src="/static/banner_2.png" class="img17 vt"></image>
							</view>
							<view class="item">
								<view class="df fldc jcsb hp100">
									<view class="fs28 lh34 cor_333 ell">{{item.name}}</view>
									<view class="fs22 cor_808">结束日期：{{item.endTime}}</view>
									<view class="fs34 fwb cor_F23">￥{{item.price}}</view>
								</view>
							</view>
						</view>
						<image  :lazy-load="true" src="/static/icon_watermark_5.png" class="watermark_img_pos"></image>
					</view>

					<view v-if="list.length == 0" style="width: 100%;height: 100vh;">
						<view style="height: 200rpx;"></view>

						<image  :lazy-load="true" src="../../static/excavator.png" style="width: 100%; padding: 100rpx 200rpx;">
						</image>
						<view style="width: 100%;text-align: center;color: #808080;">暂无数据</view>
					</view>

				</view>
			</view>
		</view><!-- box -->
	</view>
</template>

<script>
	import {
		toast,
		showLoading,
		hideLoading
	} from '@/utils/toast.js';
	import {
		getMyDatumPageApi
	} from '@/http/api.js';
	export default {
		data() {
			return {
				pageIndex: 1,
				pageSize: 10,
				list: []
			}
		},
		onLoad() {
			try {
				const userInfo = uni.getStorageSync('userInfo');
				if (UserInfo.beMember) {
					uni.showModal({
						title: '提示',
						content: '您是我们的会员，所有资料均可免费浏览！！！',
						showCancel: false,
						success: function(res) {
							if (res.confirm) {
								console.log('用户点击确定');
								uni.navigateBack();
							}
						}
					});
				} else {
					this.getMyDatumPage();
				}
			} catch (err) {
				this.getMyDatumPage();
			}

		},
		methods: {
			getMyDatumPage() {
				let that = this;
				showLoading('加载中');
				getMyDatumPageApi({
					userId: uni.getStorageSync('userId'),
					pageIndex: this.pageIndex,
					pageSize: this.pageSize,
				}).then(res => {
					toast(res.data);
					if (res.data.hasNextPage) {
						that.pageIndex = res.data.currentPage + 1;
					}
					for (let i in res.data.data) {
						that.list.push(res.data.data[i]);
					}
					hideLoading();
				}).catch(err => {
					hideLoading();
				})
			}
		}
	}
</script>

<style>
	.menu_content_box_page {
		position: relative;
		/* height: 100vh; */
		background-color: #f7f6f6;
	}

	.area_block_1 {
		position: relative;
		padding: 32rpx 135rpx 30rpx 20rpx;
		background-color: #fff;
		border-radius: 20rpx;
	}

	.watermark_img_pos {
		position: absolute;
		right: 10rpx;
		bottom: 18rpx;
		width: 92rpx;
		height: 92rpx;
		z-index: 2;
	}
</style>
